<template>
	<view class="content">
		<view class="chop_bg">
			
		</view>
		<view class="chop_person_out">
			<view class="chop_person">
				<view class="immediately">
					参与拼单，立即成团
				</view>
				<view class="person_header" v-if="purchasePersonData.total">
					<image src="../../static/img/bind_header.png" mode=""></image>
					<image src="../../static/img/bind_header.png" mode=""></image>
					<image src="../../static/img/bind_header.png" mode=""></image>
					<image src="../../static/img/bind_header.png" mode=""></image>
					<text class="more">4</text>
					
				</view>
				<view class="count_font">
					{{purchasePersonData.total}}人正在参与1元全城团活动
				</view>
			</view>
		</view>
		<view class="chop_record">
			<view class="chop_record_title">
				<view class="chop_record_title_lf">
					<image src="../../static/img/chop_jl.png" style="width: 24rpx;height: 27rpx;" mode=""></image>
					<text>拼团记录</text>
				</view>
				<text>已有{{purchaseList.length}}人拼团成功</text>		
			</view>
			<view class="chop_record_content" v-if="purchaseList.length">
				<view class="chop_record_content_item"  v-for="(item,index) in purchaseList" :key="index">
					<view class="lf">
						<image src="../../static/img/bind_header.png" style="width: 50rpx;height: 50rpx;" mode=""></image>
						<text class="person_name">小白菜帮</text>
						<text class="price">￥39.8</text>
					</view>
					<text>砍掉35元</text>
				    
				</view>
				
				
			</view>
			<view class="noData" v-else style="background-color: #FFFBEE;">
				找不到相关数据
			</view>
		</view>
		
		
		<view class="rightOff_box">
			<view class="base_map">
				
			</view>
			<view class="rightOff_content">
				<view class="tab_box">
					<text v-for="(item,index) in list" :key="index" @click="changeTab(index)" :class="{'active':item.isClick}">{{item.title}}</text>
					
				</view>
				<view class="chop_product" style="margin-top: 47rpx;" v-if="seckillShopsList.length">
					<view class="chop_product_item" style="margin-bottom: 20rpx;" v-for="(item,index) in seckillShopsList" :key="index" @click="goDetail(item)">
						<image :src="imageUrl+item.shopCover" mode=""></image>
						<view class="img_price">
							<view >
								{{item.shopTitle}}
							</view>
							<view >
								<text>￥{{item.shopDiscountPrice}}</text>
								<text>原价￥{{item.shopOriginalPrice}}</text>
							</view>
						</view>
					</view>
					
				</view>
				<view class="noData" v-else>
					找不到相关数据
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default{
		data(){
			return {
				list:[{
					title:'正在拼团',
					isClick:true,
				},{
					title:'马上开团',
					isClick:false,
				}],
				purchaseList:[],//拼团记录
				purchasePersonData:{},//正在参加拼团的用户
				seckillShopsList:[],//拼团的商品
				cityCode:'110101',
				index:0,
				pageRow:1,
				pageSize:10,
				imageUrl:""
			}
		},
		onShow() {
			this.bargainFun()
			this.seckillShops(this.index)
			this.purchaseFun()
		},
		methods:{
			//详情
			goDetail(item){
				//type://1秒杀，2拼团 3砍价
				//ptType :拼团类型 0正在拼团 1马上开团
				uni.navigateTo({
				    url: '../subjectSub/curriculum?id='+item.id+'&type=2'+'&ptType='+this.index
				});
			},
			changeTab(index){
				this.index=index;
				this.list.forEach((a,i)=>{
					a.isClick=false;
					if(i==index){
						a.isClick=true;
					}
				})
				this.seckillShops(this.index);
			},
			// 砍价商品
			seckillShops(type){
				this.$http.get('/api/dream/seckillShops',{
					areaCode:this.cityCode,
					pageType:type,
					partition:1,
					pageRow:this.pageRow,
					pageSize:this.pageSize
				}).then((data)=>{
					if(data.data.code==200){
						if(data.data.result){
							this.seckillShopsList=data.data.result.records||[];
							this.imageUrl=data.data.imageUrl;
						}else{
							this.seckillShopsList=[];
						}
						
					}else{
						this.seckillShopsList=[];
					}
				})
			},
			//获取砍价用户
				bargainFun(){
					this.$http.get('/api/dream/purchasePerson',{}).then((data)=>{
						if(data.data.code==200){
						  if(data.data.result){
							  this.purchasePersonData=data.data.result
						  }	
						}
					})
				},
				//拼团记录
				purchaseFun(){
					this.$http.get('/api/dream/purchase',{
						areaCode:this.cityCode,
						pageRow:1,
						pageSize:10,
						pageType:2,
						partition:1
					}).then((data)=>{
						if(data.data.code==200){
						  if(data.data.result){
							  this.purchaseList=data.data.result.records||[];
							  console.log(data.data.result)
						  }	
						}
					})
				}
		}
	}
</script>

<style lang="scss" scoped>
	@import '@/static/css/wholeCityRegiment.scss'
</style>
